#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
    int f = 0, ans = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
constexpr int N = 2.5e3 + 5, A = 5e3 + 5;
int n, k, a[N], b[N];
int f[N][A];
inline int get(int l, int r) { return l <= r ? b[r] - b[l - 1] : 0; }
signed main()
{
    freopen("festival.in", "r", stdin);
    freopen("festival.out", "w", stdout);
    int case_id = read(), T = read();
    while (T--)
    {
        for (int i = 0; i <= n; ++i)
            memset(f[i], 0, sizeof(f[i]));
        n = read(), k = read();
        for (int i = 2; i <= n; ++i)
            a[i] = read();
        a[1] = a[2];
        for (int i = 1; i <= k; ++i)
            b[i] = b[i - 1] + read();
        for (int i = 1; i <= n; ++i)
        {
            int val = get(max(i - (n - k), 1ll), min(i, k));
            int mx = 0;
            for (int j = a[i]; ~j; --j)
            {
                mx = max(mx, f[i - 1][a[i] - j]);
                f[i][j] = mx + val * j;
#ifdef _DEBUG
                cerr << "i:j:f: " << i << ' ' << j << ' ' << f[i][j] << endl;
#endif
            }
        }
        write(*max_element(begin(f[n]), end(f[n]))), putchar('\n');
    }
    return 0;
}